﻿using BestPracticesMVC.BL.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

namespace BestPracticesMVC.HtmlHelpers
{
    public static class HtmlExtensions
    {
        public static MvcHtmlString TestHelper(this HtmlHelper htmlHelper,
            ICollection<AuthorViewModel> list)
        {
            //declare the html helper 
            var ul = new TagBuilder("ul"); 

            foreach (var item in list)
            {
                var li = new TagBuilder("li");
                li.InnerHtml = item.Name + " " + (item.NickName == null ? "No nick name" : item.NickName);
                ul.InnerHtml += li.ToString();
            }
          
            return MvcHtmlString.Create(ul.ToString());
        }
    }
}